package net.hn.hnms.biz.activiti.company.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import net.hn.hnms.biz.activiti.domain.MyProcess;
import net.hn.hnms.biz.common.jpa.utils.HqlUtils;
import net.hn.hnms.sys.common.core.domain.R;
import net.hn.hnms.biz.common.jpa.utils.ResponsePage;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.persistence.EntityManager;

/**
 * Author: PanSX
 * Date: 2023/9/5 13:38
 */
@RestController
@AllArgsConstructor
@RequestMapping("company/act/api")
@Api(value = "流程接口", tags = "流程接口-公司端")
public class CompanyController {
    private final EntityManager entityManager;
    @GetMapping("table/pageList")
    @ApiOperation("分页查询")
    public R<ResponsePage<MyProcess>> getPageList(@RequestParam(defaultValue = "0") int pageNum, @RequestParam(defaultValue = "20") int pageSize, MyProcess process){
        PageRequest pageRequest = PageRequest.of(pageNum, pageSize);
        process.setUpdateTime(null);
        ResponsePage page = HqlUtils.findPage(entityManager, process,
                pageRequest, "", Sort.by(Sort.Direction.DESC, "updateTime"));
        return R.ok(page);
    }
}
